using System;
using System.Data;
using System.Collections.Generic;
namespace CMS.DAO{
	/********************************BEGIN tblProductDAOBase****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v1.0</para>
	/// <para>Date:11-03-2012 21:08:46</para>
	/// <para>Class Name: tblProductDAOBase</para>
	/// <para>Description: Class access to table tblProduct in database. Coder should'nt code here.</para>
	///</summary>

	
	public abstract class tblProductDAOBase : CMSDAO<tblProductEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: ProductId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int ProductId){
            IDbCommand cmd = this.CreateCommand("tblProduct_GetById");
			cmd.CommandType=CommandType.StoredProcedure;
			this.CreateCommandParameter(cmd,"@ProductId",ProductId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: ProductId</para>
		/// <para>Output: tblProductEntity</para>
		///</summary>
		public tblProductEntity SelectOne(int ProductId){
			IDbCommand cmd=this.CreateSelectOneCommand(ProductId);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateCountCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateCountCommand(){
			IDbCommand cmd=this.CreateCommand("tblProductCount");
			cmd.CommandType=CommandType.StoredProcedure;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: Count</para>
		/// <para>Input: </para>
		/// <para>Output: return number of rows return</para>
		///</summary>
		public long Count(){
			IDbCommand cmd=this.CreateCountCommand();
			long result=0;
			DataSet dtSet=this.SelectDS(cmd);
			if(dtSet.Tables.Count>0){
				if(dtSet.Tables[0].Rows.Count>0){
					try{
						result=Convert.ToInt64(dtSet.Tables[0].Rows[0][0]);
					}catch{}
				}
			}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateCountByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateCountByKeyCommand(string ColumnName,object Value){
			IDbCommand cmd=this.CreateCommand("tblProductCountBy"+ColumnName);
			cmd.CommandType=CommandType.StoredProcedure;
			this.CreateCommandParameter(cmd,"@ColumnValue",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			IDbCommand cmd=this.CreateCommand("tblProductSelectAll");
			cmd.CommandType=CommandType.StoredProcedure;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			IDbCommand cmd=this.CreateCommand("tblProductSelectAllBy"+ColumnName);
			cmd.CommandType=CommandType.StoredProcedure;
			this.CreateCommandParameter(cmd,"@ColumnValue",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of tblProductEntity</para>
		///</summary>
		public List<tblProductEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: tblProductEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(tblProductEntity o){
			IDbCommand cmd=this.CreateCommand("tblProductInsert");
			cmd.CommandType=CommandType.StoredProcedure;
			if(o.IsNullCategoryId)
				this.CreateCommandParameter(cmd,"@CategoryId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@CategoryId",o.CategoryId);

			if(o.IsNullProductName)
				this.CreateCommandParameter(cmd,"@ProductName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductName",o.ProductName);

			if(o.IsNullProductCode)
				this.CreateCommandParameter(cmd,"@ProductCode",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductCode",o.ProductCode);

			if(o.IsNullDesciption)
				this.CreateCommandParameter(cmd,"@Desciption",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Desciption",o.Desciption);

			if(o.IsNullShortTitle)
				this.CreateCommandParameter(cmd,"@ShortTitle",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ShortTitle",o.ShortTitle);

			if(o.IsNullImage)
				this.CreateCommandParameter(cmd,"@Image",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Image",o.Image);

			if(o.IsNullInputDate)
				this.CreateCommandParameter(cmd,"@InputDate",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@InputDate",o.InputDate);

			if(o.IsNullPriceInput)
				this.CreateCommandParameter(cmd,"@PriceInput",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PriceInput",o.PriceInput);

			if(o.IsNullDiscountPrice)
				this.CreateCommandParameter(cmd,"@DiscountPrice",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiscountPrice",o.DiscountPrice);

			if(o.IsNullSalePrice)
				this.CreateCommandParameter(cmd,"@SalePrice",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SalePrice",o.SalePrice);

			if(o.IsNullRealPrice)
				this.CreateCommandParameter(cmd,"@RealPrice",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@RealPrice",o.RealPrice);

			if(o.IsNullPromotion)
				this.CreateCommandParameter(cmd,"@Promotion",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Promotion",o.Promotion);

			if(o.IsNullisPromotion)
				this.CreateCommandParameter(cmd,"@isPromotion",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@isPromotion",o.isPromotion);

			if(o.IsNullIsHome)
				this.CreateCommandParameter(cmd,"@IsHome",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsHome",o.IsHome);

			if(o.IsNullIsOrder)
				this.CreateCommandParameter(cmd,"@IsOrder",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsOrder",o.IsOrder);

			if(o.IsNullProductNameOther)
				this.CreateCommandParameter(cmd,"@ProductNameOther",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductNameOther",o.ProductNameOther);

			if(o.IsNullQuantity)
				this.CreateCommandParameter(cmd,"@Quantity",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Quantity",o.Quantity);

			if(o.IsNullfrkUnitId)
				this.CreateCommandParameter(cmd,"@frkUnitId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@frkUnitId",o.frkUnitId);

			if(o.IsNullUnitName)
				this.CreateCommandParameter(cmd,"@UnitName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UnitName",o.UnitName);

			if(o.IsNullStar)
				this.CreateCommandParameter(cmd,"@Star",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Star",o.Star);

			if(o.IsNullActive)
				this.CreateCommandParameter(cmd,"@Active",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Active",o.Active);

			if(o.IsNullIsProductHot)
				this.CreateCommandParameter(cmd,"@IsProductHot",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsProductHot",o.IsProductHot);

			if(o.IsNullWanrantyMonth)
				this.CreateCommandParameter(cmd,"@WanrantyMonth",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@WanrantyMonth",o.WanrantyMonth);

			if(o.IsNullUserId)
				this.CreateCommandParameter(cmd,"@UserId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserId",o.UserId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: Save</para>
		/// <para>Input: tblProductEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(tblProductEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.ProductId=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of tblProductEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<tblProductEntity>list){
			foreach(tblProductEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: tblProductEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(tblProductEntity o){
			IDbCommand cmd=this.CreateCommand("tblProductUpdate");
			cmd.CommandType=CommandType.StoredProcedure;
			if(o.IsNullProductId)
				this.CreateCommandParameter(cmd,"@ProductId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductId",o.ProductId);

			if(o.IsNullCategoryId)
				this.CreateCommandParameter(cmd,"@CategoryId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@CategoryId",o.CategoryId);

			if(o.IsNullProductName)
				this.CreateCommandParameter(cmd,"@ProductName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductName",o.ProductName);

			if(o.IsNullProductCode)
				this.CreateCommandParameter(cmd,"@ProductCode",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductCode",o.ProductCode);

			if(o.IsNullDesciption)
				this.CreateCommandParameter(cmd,"@Desciption",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Desciption",o.Desciption);

			if(o.IsNullShortTitle)
				this.CreateCommandParameter(cmd,"@ShortTitle",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ShortTitle",o.ShortTitle);

			if(o.IsNullImage)
				this.CreateCommandParameter(cmd,"@Image",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Image",o.Image);

			if(o.IsNullInputDate)
				this.CreateCommandParameter(cmd,"@InputDate",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@InputDate",o.InputDate);

			if(o.IsNullPriceInput)
				this.CreateCommandParameter(cmd,"@PriceInput",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PriceInput",o.PriceInput);

			if(o.IsNullDiscountPrice)
				this.CreateCommandParameter(cmd,"@DiscountPrice",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiscountPrice",o.DiscountPrice);

			if(o.IsNullSalePrice)
				this.CreateCommandParameter(cmd,"@SalePrice",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SalePrice",o.SalePrice);

			if(o.IsNullRealPrice)
				this.CreateCommandParameter(cmd,"@RealPrice",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@RealPrice",o.RealPrice);

			if(o.IsNullPromotion)
				this.CreateCommandParameter(cmd,"@Promotion",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Promotion",o.Promotion);

			if(o.IsNullisPromotion)
				this.CreateCommandParameter(cmd,"@isPromotion",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@isPromotion",o.isPromotion);

			if(o.IsNullIsHome)
				this.CreateCommandParameter(cmd,"@IsHome",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsHome",o.IsHome);

			if(o.IsNullIsOrder)
				this.CreateCommandParameter(cmd,"@IsOrder",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsOrder",o.IsOrder);

			if(o.IsNullProductNameOther)
				this.CreateCommandParameter(cmd,"@ProductNameOther",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductNameOther",o.ProductNameOther);

			if(o.IsNullQuantity)
				this.CreateCommandParameter(cmd,"@Quantity",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Quantity",o.Quantity);

			if(o.IsNullfrkUnitId)
				this.CreateCommandParameter(cmd,"@frkUnitId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@frkUnitId",o.frkUnitId);

			if(o.IsNullUnitName)
				this.CreateCommandParameter(cmd,"@UnitName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UnitName",o.UnitName);

			if(o.IsNullStar)
				this.CreateCommandParameter(cmd,"@Star",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Star",o.Star);

			if(o.IsNullActive)
				this.CreateCommandParameter(cmd,"@Active",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Active",o.Active);

			if(o.IsNullIsProductHot)
				this.CreateCommandParameter(cmd,"@IsProductHot",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@IsProductHot",o.IsProductHot);

			if(o.IsNullWanrantyMonth)
				this.CreateCommandParameter(cmd,"@WanrantyMonth",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@WanrantyMonth",o.WanrantyMonth);

			if(o.IsNullUserId)
				this.CreateCommandParameter(cmd,"@UserId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserId",o.UserId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: Update</para>
		/// <para>Input: tblProductEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(tblProductEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of tblProductEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<tblProductEntity>list){
			foreach(tblProductEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			IDbCommand cmd=this.CreateCommand("tblProductDeleteAll");
			cmd.CommandType=CommandType.StoredProcedure;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: tblProductEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(tblProductEntity o){
			IDbCommand cmd=this.CreateCommand("tblProductDelete");
			cmd.CommandType=CommandType.StoredProcedure;
			if(o.IsNullProductId)
				this.CreateCommandParameter(cmd,"@ProductId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ProductId",o.ProductId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: ProductId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int ProductId){
			IDbCommand cmd=this.CreateCommand("tblProductDelete");
			cmd.CommandType=CommandType.StoredProcedure;
			this.CreateCommandParameter(cmd,"@ProductId",ProductId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			IDbCommand cmd=this.CreateCommand("tblProductDeleteBy"+ColumnName);
			cmd.CommandType=CommandType.StoredProcedure;
			this.CreateCommandParameter(cmd,"@ColumnValue",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: Delete</para>
		/// <para>Input: tblProductEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(tblProductEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: ProductId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int ProductId){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(ProductId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select,delete by ProductId functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v1.0</para>
		/// <para>Date:11-03-2012 21:08:46</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: tblProductEntity</para>
		///</summary>
		protected override tblProductEntity MapObject(IDataReader r){
			tblProductEntity entity = new tblProductEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("ProductId");
						if (!r.IsDBNull(ordinal)) entity.ProductId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("CategoryId");
						if (!r.IsDBNull(ordinal)) entity.CategoryId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("ProductName");
						if (!r.IsDBNull(ordinal)) entity.ProductName = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("ProductCode");
						if (!r.IsDBNull(ordinal)) entity.ProductCode = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Desciption");
						if (!r.IsDBNull(ordinal)) entity.Desciption = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("ShortTitle");
						if (!r.IsDBNull(ordinal)) entity.ShortTitle = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Image");
						if (!r.IsDBNull(ordinal)) entity.Image = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("InputDate");
						if (!r.IsDBNull(ordinal)) entity.InputDate = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("PriceInput");
						if (!r.IsDBNull(ordinal)) entity.PriceInput = ((Decimal)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DiscountPrice");
						if (!r.IsDBNull(ordinal)) entity.DiscountPrice = ((Decimal)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("SalePrice");
						if (!r.IsDBNull(ordinal)) entity.SalePrice = ((Decimal)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("RealPrice");
						if (!r.IsDBNull(ordinal)) entity.RealPrice = ((Decimal)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Promotion");
						if (!r.IsDBNull(ordinal)) entity.Promotion = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("isPromotion");
						if (!r.IsDBNull(ordinal)) entity.isPromotion = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("IsHome");
						if (!r.IsDBNull(ordinal)) entity.IsHome = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("IsOrder");
						if (!r.IsDBNull(ordinal)) entity.IsOrder = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("ProductNameOther");
						if (!r.IsDBNull(ordinal)) entity.ProductNameOther = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Quantity");
						if (!r.IsDBNull(ordinal)) entity.Quantity = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("frkUnitId");
						if (!r.IsDBNull(ordinal)) entity.frkUnitId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("UnitName");
						if (!r.IsDBNull(ordinal)) entity.UnitName = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Star");
						if (!r.IsDBNull(ordinal)) entity.Star = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Active");
						if (!r.IsDBNull(ordinal)) entity.Active = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("IsProductHot");
						if (!r.IsDBNull(ordinal)) entity.IsProductHot = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("WanrantyMonth");
						if (!r.IsDBNull(ordinal)) entity.WanrantyMonth = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("UserId");
						if (!r.IsDBNull(ordinal)) entity.UserId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END tblProductDAOBase*****************************************/
	/*****************************************************************************************************/
}

